package java7;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.nio.file.Paths;
import java.util.logging.Logger;

/**
 * 自动资源管理
 *
 * @author user
 */
public class J1 {
    private static final Logger log = Logger.getLogger(J1.class.getSimpleName());

    public static void main(String[] args) {
        File file = Paths.get("D:/1.txt").toFile();
        try (FileInputStream fis = new FileInputStream(file);
             FileOutputStream fos = new FileOutputStream(file)) {
            byte[] bytes = new byte[1024 * 1024];
            int size = fis.read(bytes);
            log.info("读取到的字段长度:" + size);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

}
